home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / e / ddmoduls.lha / dd_Modules / dd_gui / dd_onlinehelp.e < prev    next >
Text File  |  1995-08-13  |  4KB  |  148 lines

  1. OPT MODULE
  2.  
  3. MODULE 'amigaguide'
  4. MODULE 'libraries/amigaguide'
  5. MODULE 'utility/tagitem'
  6.  
  7. ENUM OLH_NO_ERROR,OLH_CANNOT_OPEN
  8.  
  9. DEF amigaguidebase
  10.  
  11. EXPORT OBJECT onlinehelp
  12. PRIVATE
  13.   -> amigaguide database information
  14.   guide:newamigaguide
  15.   -> handle for amigaguide
  16.   handle
  17.   -> current context index number
  18.   context
  19. PUBLIC
  20.   -> signal mask indicates amigaguide messages
  21.   signalmask:LONG
  22. ENDOBJECT
  23.  
  24. EXPORT PROC new(guidefile,arexxname,basename,contextlist) OF onlinehelp
  25.   self.guide.name:=guidefile
  26.   self.guide.clientport:=arexxname
  27.   self.guide.basename:=basename
  28.   self.guide.flags:=HTF_CACHE_NODE
  29.   self.guide.context:=contextlist
  30. ENDPROC TRUE
  31.  
  32. EXPORT PROC end() OF onlinehelp
  33.   self.close()
  34.   self.context:=0
  35.   self.signalmask:=0
  36. ENDPROC
  37.  
  38. PROC close() OF onlinehelp
  39.   -> amigaguide.library open?
  40.   IF amigaguidebase
  41.     -> amigaguide opened?
  42.     IF self.handle
  43.       -> close the amigaguide
  44.       CloseAmigaGuide(self.handle)
  45.       self.handle:=NIL
  46.     ENDIF
  47.     -> close the amigaguide.library
  48.     CloseLibrary(amigaguidebase)
  49.     amigaguidebase:=NIL
  50.   ENDIF
  51. ENDPROC
  52.  
  53. EXPORT PROC help() OF onlinehelp
  54.  
  55.   -> amigaguide.library not opened?
  56.   IF amigaguidebase=NIL
  57.     -> try to open amigaguide.library
  58.     amigaguidebase:=OpenLibrary('amigaguide.library',34)
  59.   ENDIF
  60.  
  61.   -> amigaguide.library open?
  62.   IF amigaguidebase
  63.     -> guide already open?
  64.     IF self.handle
  65.       -> is set context valid?
  66.       IF SetAmigaGuideContextA(self.handle,self.context,NIL)
  67.         -> send valid context to be displayed
  68.         SendAmigaGuideContextA(self.handle,NIL)
  69.       ENDIF
  70.     -> guide is not open yet
  71.     ELSE
  72.       -> open the guide. note that we will be notified by a message
  73.       -> later when the guide is actually displayed
  74.       self.handle:=OpenAmigaGuideAsyncA(self.guide,TAG_DONE)
  75.       -> amigaguide opened?
  76.       IF self.handle
  77.         -> get the signalmask for this amigaguide
  78.         self.signalmask:=AmigaGuideSignal(self.handle)
  79.       ELSE
  80.         -> handle errors here
  81.         PrintF('Could not show the online help guide.\n')
  82.       ENDIF
  83.     ENDIF
  84.   ELSE
  85.     PrintF('The amigaguide.library version 34 is not available.\n',)
  86.   ENDIF
  87. ENDPROC
  88.  
  89. EXPORT PROC setcontext(contextindex) OF onlinehelp
  90.   -> just store new context
  91.   self.context:=contextindex
  92. ENDPROC
  93.  
  94. EXPORT PROC signalmask() OF onlinehelp IS self.signalmask
  95.  
  96. EXPORT PROC handle() OF onlinehelp
  97.   DEF message=NIL:PTR TO amigaguidemsg
  98.   DEF error=OLH_NO_ERROR
  99.   -> check if there is something to handle
  100.   IF (amigaguidebase<>NIL) AND (self.handle<>NIL)
  101.     -> get the next amigaguide message, if any
  102.     WHILE message:=GetAmigaGuideMsg(self.handle)
  103.       -> guide has become active?
  104.       IF (message.type=ACTIVETOOLID)
  105.         -> help must have been wanted before, so call it again
  106.         self.help()
  107.       -> other messages
  108.       ELSEIF (message.type=TOOLSTATUSID) OR
  109.              (message.type=TOOLCMDREPLYID) OR
  110.              (message.type=SHUTDOWNMSGID)
  111.         PrintF('message.type=\d\n',message.type)
  112.         -> primary return value indicates error?
  113.         IF message.pri_ret
  114.           -> you could instruct the user here
  115.           IF message.sec_ret=HTERR_CANT_OPEN_DATABASE
  116.             -> set the error to be acted upon later
  117.             PrintF('setting error.\n')
  118.             error:=OLH_CANNOT_OPEN
  119.           -> other errors, probably just show them
  120.           ELSE
  121.             PrintF('AmigaGuide Error:\n\s\n',GetAmigaGuideString(message.sec_ret))
  122.           ENDIF
  123.         ENDIF
  124.       ENDIF
  125.       -> we are finished with this message, let's reply it
  126.       ReplyAmigaGuideMsg(message)
  127.     ENDWHILE
  128.     -> did an error occur?
  129.     IF error=OLH_CANNOT_OPEN
  130.       PrintF('acting on error.\n')
  131.       self.retry()
  132.     ENDIF
  133.   ENDIF
  134. ENDPROC
  135.  
  136. PROC retry() OF onlinehelp
  137.   -> close down the faulty amigaguide
  138.   self.close()
  139.   -> ask for the correct filename
  140.   self.guide.name:='dd_onlinehelptest3.guide'
  141.   -> if give, try again
  142.   self.help()
  143. ENDPROC
  144.  
  145.  
  146.  
  147.  
  148.